<template>
  <div>
   <h1>ref获取原生DOM元素</h1>
   <div ref='box' id="box">我是一个div盒子</div>
   <button @click="getBox">点我获取div盒子</button>
   <hr>
   <h1>ref获取组件元素</h1>
   <my-demo ref="demo" ></my-demo >
   <button @click="getDemo">点我获取demo</button>
  </div>
</template>

<script>
import MyDemo from './components/MyDemo.vue'

export default {
  components: { MyDemo },

data(){
  return{
   
  }
},
methods:{
  getBox(){
    console.log(this.$refs.box)
  },
  getDemo(){
    console.log(this.$refs.demo)
    console.log(this.$refs.demo.msg)
    this.$refs.demo.demoFn()

  }
}
}
</script>

<style>

</style>